package com.mall.b2c.lucene;

import com.mall.b2c.service.LuceneService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.Resource;
import java.util.Date;

/**
 * Created by lzx on 2015/4/27.
 * spring加载完成后，初始化商品索引
 */
public class InitBuildGoodsIndex implements InitializingBean{

    @Resource private LuceneService luceneService;

    private final Logger log = Logger.getLogger(getClass());

    @Override
    public void afterPropertiesSet() throws Exception {
        try {
            luceneService.indexGoods(null, new Date(), null);
        }catch (Exception e){
            log.error("初始化商品索引失败，请手动执行",e);
        }
    }
}
